from typing import List
from pydantic import Field, BaseModel
from package.fastapi.schema import Page, BatchId
from ..devops.schema import DevopsOut


class EditSource(BaseModel):
    description: str = Field('-', title='数据源描述')
    configure: dict = Field(None, title='数据源配置')


class Source(EditSource):
    name: str = Field(..., title='数据源名称')
    category: str = Field(..., title='数据源类型')
    devops_id: str = Field(None, title='数据源对应的运维对象')


class SourceOut(Source):
    id: str = Field(..., title='ID')
    devops: DevopsOut = Field(None, title='devops')

    class Config:
        orm_mode = True


class PageSource(Page):
    data: List[SourceOut] = Field(..., title='')
